<!doctype html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../assert_selection.js"></script>
<script>
const isMac = navigator.platform.indexOf('Mac') === 0;
const kBehaviors = window.internals ? ['mac', 'win'] : isMac ? ['mac'] : ['win'];
for (const behavior of kBehaviors) {
  if (window.internals) {
    internals.settings.setEditingBehavior(behavior);
    internals.settings.setSelectTrailingWhitespaceEnabled(behavior !== 'mac');
  }

selection_test(
  '<div contenteditable dir="rtl">|car means \u05D0\u05D1\u05D2.</div>',
  selection => selection.modify('extend', 'forward', 'word'),
  behavior === 'mac'
      ? '<div contenteditable dir="rtl">^car| means \u05D0\u05D1\u05D2.</div>'
      : '<div contenteditable dir="rtl">^car |means \u05D0\u05D1\u05D2.</div>',
  `${behavior} 16-0 rtl forward word`);

selection_test(
  '<div contenteditable dir="rtl">c|ar means \u05D0\u05D1\u05D2.</div>',
  selection => selection.modify('extend', 'forward', 'word'),
  behavior === 'mac'
      ? '<div contenteditable dir="rtl">c^ar| means \u05D0\u05D1\u05D2.</div>'
      : '<div contenteditable dir="rtl">c^ar |means \u05D0\u05D1\u05D2.</div>',
  `${behavior} 16-1 rtl forward word`);

selection_test(
  '<div contenteditable dir="rtl">ca|r means \u05D0\u05D1\u05D2.</div>',
  selection => selection.modify('extend', 'forward', 'word'),
  behavior === 'mac'
      ? '<div contenteditable dir="rtl">ca^r| means \u05D0\u05D1\u05D2.</div>'
      : '<div contenteditable dir="rtl">ca^r |means \u05D0\u05D1\u05D2.</div>',
  `${behavior} 16-2 rtl forward word`);

selection_test(
  '<div contenteditable dir="rtl">car| means \u05D0\u05D1\u05D2.</div>',
  selection => selection.modify('extend', 'forward', 'word'),
  behavior === 'mac'
      ? '<div contenteditable dir="rtl">car^ means| \u05D0\u05D1\u05D2.</div>'
      : '<div contenteditable dir="rtl">car^ |means \u05D0\u05D1\u05D2.</div>',
  `${behavior} 16-3 rtl forward word`);

selection_test(
  '<div contenteditable dir="rtl">car |means \u05D0\u05D1\u05D2.</div>',
  selection => selection.modify('extend', 'forward', 'word'),
  behavior === 'mac'
      ? '<div contenteditable dir="rtl">car ^means| \u05D0\u05D1\u05D2.</div>'
      : '<div contenteditable dir="rtl">car ^means |\u05D0\u05D1\u05D2.</div>',
  `${behavior} 16-4 rtl forward word`);

selection_test(
  '<div contenteditable dir="rtl">car m|eans \u05D0\u05D1\u05D2.</div>',
  selection => selection.modify('extend', 'forward', 'word'),
  behavior === 'mac'
      ? '<div contenteditable dir="rtl">car m^eans| \u05D0\u05D1\u05D2.</div>'
      : '<div contenteditable dir="rtl">car m^eans |\u05D0\u05D1\u05D2.</div>',
  `${behavior} 16-5 rtl forward word`);

selection_test(
  '<div contenteditable dir="rtl">car me|ans \u05D0\u05D1\u05D2.</div>',
  selection => selection.modify('extend', 'forward', 'word'),
  behavior === 'mac'
      ? '<div contenteditable dir="rtl">car me^ans| \u05D0\u05D1\u05D2.</div>'
      : '<div contenteditable dir="rtl">car me^ans |\u05D0\u05D1\u05D2.</div>',
  `${behavior} 16-6 rtl forward word`);

selection_test(
  '<div contenteditable dir="rtl">car mea|ns \u05D0\u05D1\u05D2.</div>',
  selection => selection.modify('extend', 'forward', 'word'),
  behavior === 'mac'
      ? '<div contenteditable dir="rtl">car mea^ns| \u05D0\u05D1\u05D2.</div>'
      : '<div contenteditable dir="rtl">car mea^ns |\u05D0\u05D1\u05D2.</div>',
  `${behavior} 16-7 rtl forward word`);

selection_test(
  '<div contenteditable dir="rtl">car mean|s \u05D0\u05D1\u05D2.</div>',
  selection => selection.modify('extend', 'forward', 'word'),
  behavior === 'mac'
      ? '<div contenteditable dir="rtl">car mean^s| \u05D0\u05D1\u05D2.</div>'
      : '<div contenteditable dir="rtl">car mean^s |\u05D0\u05D1\u05D2.</div>',
  `${behavior} 16-8 rtl forward word`);

selection_test(
  '<div contenteditable dir="rtl">car means| \u05D0\u05D1\u05D2.</div>',
  selection => selection.modify('extend', 'forward', 'word'),
  behavior === 'mac'
      ? '<div contenteditable dir="rtl">car means^ \u05D0\u05D1\u05D2|.</div>'
      : '<div contenteditable dir="rtl">car means^ |\u05D0\u05D1\u05D2.</div>',
  `${behavior} 16-9 rtl forward word`);

selection_test(
  '<div contenteditable dir="rtl">car means |\u05D0\u05D1\u05D2.</div>',
  selection => selection.modify('extend', 'forward', 'word'),
  '<div contenteditable dir="rtl">car means ^\u05D0\u05D1\u05D2|.</div>',
  `${behavior} 16-10 rtl forward word`);

selection_test(
  '<div contenteditable dir="rtl">car means \u05D0|\u05D1\u05D2.</div>',
  selection => selection.modify('extend', 'forward', 'word'),
  '<div contenteditable dir="rtl">car means \u05D0^\u05D1\u05D2|.</div>',
  `${behavior} 16-11 rtl forward word`);

selection_test(
  '<div contenteditable dir="rtl">car means \u05D0\u05D1|\u05D2.</div>',
  selection => selection.modify('extend', 'forward', 'word'),
  '<div contenteditable dir="rtl">car means \u05D0\u05D1^\u05D2|.</div>',
  `${behavior} 16-12 rtl forward word`);

selection_test(
  '<div contenteditable dir="rtl">car means \u05D0\u05D1\u05D2|.</div>',
  selection => selection.modify('extend', 'forward', 'word'),
  '<div contenteditable dir="rtl">car means \u05D0\u05D1\u05D2^.|</div>',
  `${behavior} 16-13 rtl forward word`);
}
</script>
